﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Gift.DAL;
using Gift.Model;
using Gift.WebApp;

namespace WebApp.admin.system
{
    public partial class setPassword : BaseAdmin
    {
        tbAdminLogin oAdminLogin = new tbAdminLogin();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            oAdminLogin = BaseFactory.theAdmin.GetModel(base.Administrator.AdminUser, re.EncodeMD5(this.txtOldPwd.Value.Trim()));
            if(oAdminLogin == null)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"pas","<script>alert('原始密码不正确！');</script>");
            }
            else
            {
                oAdminLogin.AdminPwd = re.EncodeMD5(this.txtUserPwd.Value.Trim());
                if (BaseFactory.theAdmin.Update(oAdminLogin) > 0)
                {
                      Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"pas","<script>alert('修改成功！');</script>");
                }else
                {
                      Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"pas","<script>alert('修改失败！');</script>");
                }
            }
        }
    }
}